package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author Li_Jx
 * @description: 省/直辖市名枚举类
 * @date 2023/9/11 11:31
 */
public enum AdminDivisionProvince {
    SHAN_XI("140000", "山西"),
    SI_CHUAN("510000", "四川"),
    YUN_NAN("530000", "云南"),
    GUI_ZHOU("520000", "贵州"),
    GUANG_XI("450000", "广西"),
    GAN_SU("620000", "甘肃"),
    QING_HAI("630000", "青海"),
    NING_XIA("640000", "宁夏"),
    XI_ZANG("540000", "西藏"),
    XIN_JIANG("650000", "新疆"),
    NEI_MENG_GU("150000", "内蒙古"),
    CHONG_QING("500000", "重庆"),
    XIANG_GANG("810000", "香港特别行政区"),
    AO_MEN("820000", "澳门特别行政区"),
    TAI_WAN("710000", "台湾"),
    HE_BEI("130000", "河北"),
    BEI_JING("110000", "北京"),
    TIAN_JIN("120000", "天津"),
    SHAN_DONG("370000", "山东"),
    JIANG_SU("320000", "江苏"),
    SHANG_HAI("310000", "上海"),
    ZHE_JIANG("330000", "浙江"),
    FU_JIAN("350000", "福建"),
    GUANG_DONG("440000", "广东"),
    HAI_NAN("460000", "海南"),
    HE_NAN("410000", "河南"),
    AN_HUI("340000", "安徽"),
    HU_BEI("420000", "湖北"),
    JIANG_XI("360000", "江西"),
    HU_NAN("430000", "湖南"),
    LIAO_NING("210000", "辽宁"),
    JI_LIN("220000", "吉林"),
    HEI_LONG_JIANG("230000", "黑龙江"),
    SHANN_XI("610000","陕西");

    private String key;
    private String value;

    AdminDivisionProvince(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
    public static AdminDivisionProvince getObjectByKey(String key){
        for (AdminDivisionProvince adminDivisionProvince : AdminDivisionProvince.values()) {
            if (adminDivisionProvince.getKey().equals(key)){
                return adminDivisionProvince;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
    public static AdminDivisionProvince getObjectByValue(String value){
        for (AdminDivisionProvince adminDivisionProvince : AdminDivisionProvince.values()) {
            if (adminDivisionProvince.getValue().equals(value)){
                return adminDivisionProvince;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}

